/* Ejercicio 3.17
   ejer3_17.c
*/
#include <stdio.h>

/* funcion main, el programa inicia aca */
int main( void )
{
    float gallons, miles, milespergallon, average;
    float totalgallons, totalmiles;

    totalgallons = 0;
    totalmiles = 0;

    printf( "Enter the gallons used (-1 to end): " );
    scanf( "%f", &gallons );
    while ( gallons > 0 ) {
        printf( "Enter the miles driven: " );
        scanf( "%f", &miles );
        milespergallon = miles / gallons;
        totalgallons += gallons;
        totalmiles += miles;
        printf( "The miles / gallon for this tank was: %f\n\n", milespergallon );
        printf( "Enter the gallons used (-1 to end): " );
        scanf( "%f", &gallons );
    }

    average = totalmiles / totalgallons;
    printf( "\nThe overall average miles/gallon was %f\n", average );

	return 0;
} /* fin de la funcion main */
